package com.luo.partner.service.impl;

import com.luo.common.annotation.BaseService;
import com.luo.common.base.BaseServiceImpl;
import com.luo.common.utils.Query;
import com.luo.partner.dao.mapper.TabDomainMapper;
import com.luo.partner.dao.model.TabDomain;
import com.luo.partner.dao.model.TabDomainExample;
import com.luo.partner.service.TabDomainService;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
* TabDomainService实现
* Created by laohu on 2018/9/18.
*/
@Service
@Transactional
@BaseService
public class TabDomainServiceImpl extends BaseServiceImpl<TabDomainMapper, TabDomain, TabDomainExample> implements TabDomainService {

    private static final Logger LOGGER = LoggerFactory.getLogger(TabDomainServiceImpl.class);
    
    @Value("${bootdo.domain}")
    String domain;
    
    @Autowired
    TabDomainMapper tabDomainMapper;

	@Override
	public TabDomain get(Long id) {
		List<TabDomain> list = list();
		if (list == null || list.isEmpty()) {
			// 增加一个
			TabDomain record = new TabDomain();
			record.setDomainName(domain);
			tabDomainMapper.insert(record);
			list = list();
		}
		
		return list.get(0);
	}

	@Override
	public List<TabDomain> list() {
		return tabDomainMapper.selectByExample(new TabDomainExample());
	}

	@Override
	public int save(TabDomain role) {
		return tabDomainMapper.insert(role);
	}

	@Override
	public int update(TabDomain role) {
		TabDomain record = get(null);
		TabDomainExample example = new TabDomainExample();
		example.createCriteria().andDomainNameEqualTo(record.getDomainName());
		return tabDomainMapper.updateByExample(role, example);
	}

	@Override
	public int remove(Long id) {
		return 0;
	}

	@Override
	public List<TabDomain> list(Long userId) {
		return null;
	}

	@Override
	public int batchRemove(Long[] ids) {
		return 0;
	}

	@Override
	public int count(Query query) {
		return 0;
	}




}